#include<bits/stdc++.h>
#define i64 long long
#define ull unsigned long long

using namespace std;
using ld = long double;

const int N = 1e6 + 10, INF = 0x3f3f3f3f;



void solve()
{
    ld B, t1, a1, t2, a2;
    scanf("%Lf%Lf%Lf%Lf%Lf", &B, &t1, &a1, &t2, &a2);
    int nt = t2 - t1;
    if (nt * B >= a1)
    {
        printf("%.10Lf %.10Lf\n", a1 / B, a2 / B);
        return;
    }
    a1 -= B * nt;
    ld s1 = a1 / (B / 2), s2 = a2 / (B / 2);
    if (s1 >= s2)
    {
        printf("%.10Lf %.10Lf\n",s2 + (a1 - a2) / B + nt , s2);
    }
    else
    {
        printf("%.10Lf %.10Lf\n", s1 + nt, s1 + (a2 - a1) / B);
    }
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}